package com.zero.util;

import java.io.UnsupportedEncodingException;

import org.apache.commons.codec.binary.Base64;

/**
 * 加密解密工具类
 * 
 * @author Zero
 *
 */
public class Codec {

	/**
	 * 加密
	 * 
	 * @param originalString
	 * @return
	 * @throws UnsupportedEncodingException
	 */
	public static String encode(String originalString) throws UnsupportedEncodingException {
		return new String(Base64.encodeBase64(originalString.getBytes("utf-8")));
	}

	/**
	 * 解密
	 * 
	 * @param encodeString
	 * @return
	 * @throws UnsupportedEncodingException
	 */
	public static String decode(String encodeString) throws UnsupportedEncodingException {
		return new String(Base64.decodeBase64(encodeString), "utf-8");
	}
}
